#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
const int MOD = 1e9 + 7;
int qpow(int x, int p) {
    int res = 1;
    while (p) {
        if (p & 1) {
            res = 1ll * res * x % MOD;
        }
        x = 1ll * x * x % MOD;
        p >>= 1;
    }
    return res;
}
int jc[N];
int jc_1[N];
bool f[N];
int cnt[N];
int dp[N][N];
int dp1[N][N];
int n;
int inv(int x) {
    if (x <= n && x >= 1) {
        return 1ll * jc_1[x] * jc[x - 1] % MOD;
    } else {
        return qpow(x, MOD - 2);
    }
}
int C(int n, int m) {
    if (n < m)
        return 0;
    if (m < 0)
        return 0;
    return 1ll * jc[n] * jc_1[n - m] % MOD * jc_1[m] % MOD;
}
int Cinv(int n, int m) {
    if (n < m)
        exit(-1);
    if (m < 0)
        exit(-1);
    return 1ll * jc_1[n] * jc[n - m] % MOD * jc[m] % MOD;
}
bool mark[N][N];
int main() {
    freopen("chain.in", "r", stdin);
    freopen("chain.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        char c;
        cin >> c;
        f[i] = c - '0';
    }
    for (int i = n; i >= 1; i--) {
        cnt[i] = cnt[i + 1] + f[i];
    }
    jc[0] = 1;
    jc_1[0] = 1;
    for (int i = 1; i <= n; i++) {
        jc[i] = 1ll * jc[i - 1] * i % MOD;
    }
    jc_1[n] = qpow(jc[n], MOD - 2);
    for (int i = n - 1; i >= 1; i--) {
        jc_1[i] = 1ll * jc_1[i + 1] * (i + 1) % MOD;
    }
    for(int i = n;i >= 1;i--){
        for(int j = cnt[i];j <= min(n - i + 1,cnt[1]);j++){
            if(f[i]){
                dp[i][j] = 1ll*inv(n - cnt[1])*(n - cnt[1] + 1)%MOD
                    *(1 + 1ll*dp[i + 1][j]*(n - i - (j - 1))%MOD *inv(n - cnt[1] + 1)%MOD
                        + 1ll*dp[i + 1][j - 1]*(i - 1 - (cnt[1] - j))%MOD*inv(n - cnt[1] + 1)%MOD)%MOD;
            }else{
                int p1 = 1ll*Cinv(n - i + 1,j)*C(n - i,j)%MOD,p2 = (1 - p1 + MOD)%MOD;
                if(p2 == 0){
                    dp[i][j] = dp[i + 1][j];
                }else{
                    dp[i][j] = 1ll*inv((1 - 1ll*p2*inv(n - cnt[1] + 1)%MOD + MOD)%MOD)
                        *(1ll*p1*dp[i + 1][j]%MOD 
                        + 1ll*p2*(
                            1 + 1ll*dp[i + 1][j]*inv(n - cnt[1] + 1)%MOD*(n - i - (j - 1))%MOD 
                              + 1ll*dp[i + 1][j - 1]*(i - 1 - (cnt[1] - j))%MOD*inv(n - cnt[1] + 1)%MOD )%MOD)%MOD;
                }
            }
        }
    }
    cout<<dp[1][cnt[1]]<<'\n';
}